@extends('home.parent')
@section('title','查看用户')
@section('head_js')
<script src="{{ asset('/js/tools.js').'?v='.env('VERSION') }}"></script>
<script type="text/javascript">
var user_id = {{ $data['user_id'] }};
</script>
@endsection
@section('head_css')
<link rel="stylesheet" href="{{ asset('/css/dataTables.bootstrap.css') }}">
@endsection
@section('content')
<div class="content-wrapper">
  <section class="content-header">
    <h1>
      查看用户信息
      <small></small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
      <li><a href="{{URL('admin/user/list')}}">用户列表</a></li>
      <li class="active">查看用户</li>
    </ol>
  </section>
  <section class="invoice">
    <div class="row">
      <div class="col-xs-6">
        <a href="{{ URL('admin/my/service/list') }}" class="btn btn-default"><i class="fa fa-reply"></i> 返回</a>
        <p class="lead"></p>
        <div class="table-responsive">
          <table class="table">
            <tbody>
              <tr>
                <th>用户编号</th>
                <td>{{ $data['user_id'] }}</td>
              </tr>
              <tr>
                <th>用户昵称</th>
                <td>{{ json_decode($data['nick_name'],true) }}</td>
              </tr>
              <tr>
                <th>用户姓名</th>
                <td>{{ $data['real_name'] }}</td>
              </tr>
              <tr>
                <th>手机号码</th>
                <td>{{ $data['mobile'] }}</td>
              </tr>
              <tr>
                <th>机构名称</th>
                <td>{{ $data['company'] }}</td>
              </tr>
              <tr>
                <th>职位</th>
                <td>{{ $data['profession'] }}</td>
              </tr>
              <tr>
                <th>用户来源</th>
                <td>{{ $data['user_source'] }}</td>
              </tr>
              <tr>
                <th>注册日期</th>
                <td>{{ date('Y-m-d H:i:s',$data['create_time']) }}</td>
              </tr>
              <tr>
                <th>会员有效期</th>
                @if($data['user_type'] == 1)
                <td>{{ date('Y-m-d',$data['create_time']) .'～' .date('Y-m-d',$data['deadline_time']) }}</td>
                @else
                <td>—</td>
                @endif
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div style="margin-top:50px;"><img src="{{ $data['head_img'] }}" width="250" height="300"/></div>
      <br>
      <div class="col-md-8 pull-left">
        <div class="nav-tabs-custom">
          <ul class="nav nav-tabs">
            <li class=""><a href="#tab_1" data-toggle="tab" aria-expanded="false" onclick="showTableContent(1)">服务记录</a></li>
            <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false" onclick="showTableContent(2)">机构信息</a></li>
            <li class="active"><a href="#tab_3" data-toggle="tab" aria-expanded="true">用户信息</a></li>
            <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false" onclick="showTableContent(4)">订阅课程</a></li>
            <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false" onclick="showTableContent(5)">学习历史</a></li>
            <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false" onclick="showTableContent(6)">会员记录</a></li>
            <li class=""><a href="#tab_7" data-toggle="tab" aria-expanded="false" onclick="showTableContent(7)">大会记录</a></li>
            <li class=""><a href="#tab_8" data-toggle="tab" aria-expanded="false" onclick="showTableContent(8)">标签云</a></li>
            <li class=""><a href="#tab_9" data-toggle="tab" aria-expanded="false" onclick="showTableContent(9)">订单记录</a></li>
            <li class=""><a href="#tab_10" data-toggle="tab" aria-expanded="false" onclick="showTableContent(10)">合伙人活动</a></li>
            <li class=""><a href="#tab_11" data-toggle="tab" aria-expanded="false" onclick="showTableContent(11)">直播课记录</a></li>
            <!--<li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>-->
          </ul>
          <div class="tab-content">
            <div class="tab-pane" id="tab_1">
              @include('user.user-remark')
            </div>
            <div class="tab-pane" id="tab_2">
              @include('user.company-info')
            </div>
            <div class="tab-pane active" id="tab_3">
              @include('user.user-info')
            </div>
            <div class="tab-pane" id="tab_4">
              @include('user.buy-course')
            </div>
            <div class="tab-pane" id="tab_5">
              @include('user.learn-history')
            </div>
            <div class="tab-pane" id="tab_6">
              @include('user.vip')
            </div>
            <div class="tab-pane" id="tab_7">
              @include('user.meeting')
            </div>
            <div class="tab-pane" id="tab_8">
              @include('user.user-tag')
            </div>
            <div class="tab-pane" id="tab_9">
              @include('user.user-order')
            </div>
            <div class="tab-pane" id="tab_10">
              @include('user.partner-activity')
            </div>
            <div class="tab-pane" id="tab_11">
              @include('user.live-course')
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('/js/fastclick.js') }}"></script>
<script type="text/javascript">
function showTableContent(type){
  switch(type){
    case 1://服务记录
      var url = "{{ URL('admin/user/remark') }}";
      var data = {};
      data.user_id = user_id;
      var result = puppet.myajax('get',url,data,false);
      if(result.data.length > 0){
        var tab_1_html = '';
        for(var i = 0;i < result.data.length; i++){
          tab_1_html += '<div class="media"><div class="media-left"><a href="#"><img style="border-radius: 50%;" class="media-object icon_img_css" src="'+result.data[i].head_img+'"></a>'+
            '</div><div class="media-body"><div class="inline" style="float: left;"><h4 class="media-heading">'+result.data[i].sale_user_name+'</h4><div>'+result.data[i].create_time+'</div></div>'+
            '<div style="margin:5px 80px 0 180px;">'+result.data[i].remark+'</div></div></div>';
        }
        $('#showUserRemark').html('');
        $('#showUserRemark').html(tab_1_html);
      }else{
        $('#showUserRemark').html('暂无备注');
      }
      break;
    case 2://机构信息
      $(".one-option").remove();
      var url = "{{ URL('admin/company/info') }}";
      var data = {};
      data.user_id = user_id;
      var result = puppet.myajax('get',url,data,false);
      var companyinfo = result.data.companyinfo;
      var category_list = result.data.category_list;
      if(companyinfo){
        //处理修改为下拉框之前的数据
        var revenue_scale = companyinfo.revenue_scale;
        var race_track = companyinfo.race_track;
        var users = companyinfo.users;
        updateSelect(revenue_scale,race_track,users,category_list,companyinfo.parent_category);

        $('#t2_name').val(companyinfo.name);
        $('#t2_phone').val(companyinfo.phone);
        $('#t2_project').val(companyinfo.project);
        $('#t2_address').val(companyinfo.address);
        $('#t2_website').val(companyinfo.website);
//        $('#t2_area').val(companyinfo.area);
//        $('#t2_revenue_scale').val(companyinfo.revenue_scale);
//        $('#t2_race_track').val(companyinfo.race_track);
//        $('#t2_users').val(companyinfo.users);
        $('#t2_is_online_education').val(companyinfo.is_online_education);
        $('#t2_financing_amount').val(companyinfo.financing_amount);
        $('#t2_remark').val(companyinfo.remark);
        if(!companyinfo.area || companyinfo.area == '' ){//如果地区数据为空，重置三级联动
          province();
          city();
          county();
        }else{
          var area_data = companyinfo.area.split(" ");
          province(area_data[0]);
          city(area_data[1]);
          county(area_data[2]);
          $('#t2_city').show();
          $('#t2_county').show();
        }
      }else{//机构信息不存在
        province();
        city();
        county();
        updateSelect('','','',category_list,'');

      }
      break;
    case 4://订阅课程
      break;
    case 5://学习历史
      break;
    case 6://会员记录
      break;
    case 7://大会记录
      break;
    case 8://标签云
      break;
    case 9://订单记录
        break;
    case 10://合伙人活动
        break;
    case 11://直播课记录
    default:
      break;
  }
}

//处理 修改为下拉框之前 的数据
function updateSelect(revenue_scale,race_track,users,category_list,parent_category){
  //营收规模
  if(revenue_scale != null && revenue_scale != 0){
    var count_scale=$("#revenue_scale option").length;
    var exist_scale=0;
    for(var i=0;i<count_scale;i++){
      if($("#t2_revenue_scale ").get(0).options[i].text == revenue_scale){
        var exist_scale=1;
        break;
      }
    }
    if(exist_scale == 0){
      $("#t2_revenue_scale").append("<option value='"+revenue_scale+"'>"+revenue_scale+"</option>");
      $('#t2_revenue_scale').val(revenue_scale);
    }
  }

  // 一级标签
  var htm = '';
  $.each(category_list.one_level,function(i,val){
    if(parent_category == val){
      htm += '<option class="one-option" value="'+i+'" selected>'+val+'</option>';
    }else{
      htm += '<option class="one-option" value="'+i+'">'+val+'</option>';
    }

  });
  $(htm).appendTo($("#t2_race_track"));

  //二级标签

  if(typeof category_list.two_level_list !=="undefined"){
    var two = '';
    $.each(category_list.two_level_list,function(i,val){
      if(race_track == val){
        two += '<option value="'+val+'" selected>'+val+'</option>';
      }else{
        two += '<option value="'+val+'">'+val+'</option>';
      }

    });
    $(two).appendTo($("#t2_race_track_two"));
    $("#t2_race_track_two").show();
  }

  //用户量
  if(users != null && users != 0){
    var count_users=$("#users option").length;
    var exist_users=0;
    for(var i=0;i<count_users;i++){
      if($("#t2_users ").get(0).options[i].text == users){
        var exist_users=1;
        break;
      }
    }
    if(exist_users == 0){
      $("#t2_users").append("<option value='"+users+"'>"+users+"</option>");
      $('#t2_users').val(users);
    }
  }
}
</script>
@endsection